Open History to see the last commit
1import React from 'react'
2import Link from 'next/link'
3import fetch from '../../libs/fetch'
4β
5import { useQuery } from 'react-query'
6β
7export default () => {
8 const id =
9 typeof window !== 'undefined' ? window.location.pathname.slice(1) : ''
10β
11 const { data, isLoading, isFetching } = useQuery(['repository', { id }], () =>
12 fetch('/api/data?id=' + id)
13 )
14β
15 return (
16 <div style={{ textAlign: 'center' }}>
17 <h1>{id}</h1>
18 {isLoading ? (
19 'Loading...'
20 ) : data ? (
21 <>
22 <div>
23 <p>forks: {data.forks_count}</p>
24 <p>stars: {data.stargazers_count}</p>
25 <p>watchers: {data.watchers}</p>
26 </div>
27 <div>{isFetching ? 'Background Updating...' : ' '}</div>
28 </>
29 ) : null}
30 <br />
31 <br />
32 <Link href="/">
33 <a>Back</a>
34 </Link>
35 </div>
36 )
37}